class MyHashMap:

    def __init__(self):
        """
        Initialize your data structure here.
        """
        self.size = 0
        self.cap = 37
        self.buckets = [None] * self.cap
        self.recapFactor = 0.75

    def put(self, key: int, value: int) -> None:
        """
        value will always be non-negative.
        """
        self.recap()
        hv = key % self.cap
        bucket = self.buckets[hv]
        if bucket == None:
            self.buckets[hv] = [[key, value]]
            self.size += 1
        else:
            for entry in bucket:
                if (entry[0] == key):
                    entry[1] = value
                    return
            bucket.append([key, value])
            self.size += 1

    def recap(self):
        if self.size < self.cap * self.recapFactor:
            return
        else:
            self.cap = self.cap * 2 + 1
            self.size = 0
            oldBuckets = self.buckets
            self.buckets = [None] * self.cap
            for bucket in oldBuckets:
                if bucket != None:
                    for entry in bucket:
                        self.put(entry[0], entry[1])


    def get(self, key: int) -> int:
        """
        Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
        """
        hv = key % self.cap
        bucket = self.buckets[hv]
        if bucket == None:
            return -1
        else:
            for entry in bucket:
                if (entry[0] == key):
                    return entry[1]
            return -1

    def remove(self, key: int) -> None:
        """
        Removes the mapping of the specified value key if this map contains a mapping for the key
        """
        hv = key % self.cap
        bucket = self.buckets[hv]
        if bucket != None:
            for i, entry in enumerate(bucket):
                if (entry[0] == key):
                    del bucket[i]
                    self.size -= 1
                    break


hashMap = MyHashMap();
hashMap.put(1, 1);
hashMap.put(2, 2);
print(hashMap.get(1))    # 返回 1
print(hashMap.get(3))    # 返回 -1 (未找到)
hashMap.put(2, 1);       # 更新已有的值
print(hashMap.get(2))    # 返回 1
hashMap.remove(2);       # 数据
print(hashMap.get(2))    # 返回 -1 (未找到)